home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / ww_tv.exe / EDITORS.H < prev    next >
C/C++ Source or Header  |  1992-08-21  |  16KB  |  580 lines

  1. /* ------------------------------------------------------------------------*/
  2. /*                                                                         */
  3. /*   EDITORS.H                                                             */
  4. /*                                                                         */
  5. /*   Copyright (c) Borland International 1991                              */
  6. /*   All Rights Reserved.                                                  */
  7. /*                                                                         */
  8. /*   defines the classes TIndicator, TEditor, TMemo, TFileEditor,          */
  9. /*   and TEditWindow                                                       */
  10. /*                                                                         */
  11. /*  Primatech Modification History:                                        */
  12. /*                                                                         */
  13. /*      11-06-91 JLS  Made following changes to TEditor:                   */
  14. /*                      Made some functions inline                         */
  15. /*                      Made data members private or protected             */
  16. /*                      Made setBufLen() protected                         */
  17. /*                                                                         */
  18. /*      11-07-91 JLS  Made the following changes to TEditor:               */
  19. /*                      Made the Boolean flags public again                */
  20. /*                                                                         */
  21. /*      11-12-91 JLS  Made insertText() into an inline function in the     */
  22. /*                      TEditor class.                                     */
  23. /*                                                                         */
  24. /*      11-19-91 JLS  Added alwaysWrap parm to insertBuffer() and          */
  25. /*                      deleteSelect()                                     */
  26. /*                                                                         */
  27. /*      12-02-91 JLS  Made scrollTo(int,int) into a virtual function       */
  28. /*                                                                         */
  29. /*      01-02-92 JLS  Added shutDown() to TFileEditor as in BC++ 3.0       */
  30. /*                                                                         */
  31. /*      05-20-92 JLS  Made bufChar() and bufPtr() const functions          */
  32. /*                                                                         */
  33. /*      06-08-92 JLS  Added "BaseClass" typedef to TEditor class           */
  34. /*                                                                         */
  35. /*      07-05-92 JLS  Synced with TV1.03 (BC3.10)                          */
  36. /*                                                                         */
  37. /* ------------------------------------------------------------------------*/
  38.  
  39. #if !defined( __DIR_H )
  40. #include <dir.h>
  41. #endif  // __DIR_H
  42.  
  43. #if !defined( __STRING_H )
  44. #include <string.h>
  45. #endif  // __STRING_H
  46.  
  47. #if !defined( __LIMITS_H )
  48. #include <limits.h>
  49. #endif  // __LIMITS_H
  50.  
  51. #pragma option -Vo-
  52. #if defined( __BCOPT__ ) && __BCPLUSPLUS__ > 0x0300
  53. #pragma option -po-
  54. #endif
  55.  
  56. #if !defined( __EDIT_COMMAND_CODES )
  57. #define __EDIT_COMMAND_CODES
  58.  
  59. const
  60.   ufUpdate = 0x01,
  61.   ufLine   = 0x02,
  62.   ufView   = 0x04;
  63.  
  64. const
  65.   smExtend = 0x01,
  66.   smDouble = 0x02;
  67.  
  68. const unsigned
  69.   sfSearchFailed = 0xFFFF;
  70.  
  71. const
  72.   cmSave        = 80,
  73.   cmSaveAs      = 81,
  74.   cmFind        = 82,
  75.   cmReplace     = 83,
  76.   cmSearchAgain = 84,
  77.   cmReplaceAgain = 85,
  78.   cmToggleWrap  = 86,
  79.   cmToggleAutoMargin = 87;
  80.  
  81. const
  82.   cmCharLeft    = 500,
  83.   cmCharRight   = 501,
  84.   cmWordLeft    = 502,
  85.   cmWordRight   = 503,
  86.   cmLineStart   = 504,
  87.   cmLineEnd     = 505,
  88.   cmLineUp      = 506,
  89.   cmLineDown    = 507,
  90.   cmPageUp      = 508,
  91.   cmPageDown    = 509,
  92.   cmTextStart   = 510,
  93.   cmTextEnd     = 511,
  94.   cmNewLine     = 512,
  95.   cmBackSpace   = 513,
  96.   cmDelChar     = 514,
  97.   cmDelWord     = 515,
  98.   cmDelStart    = 516,
  99.   cmDelEnd      = 517,
  100.   cmDelLine     = 518,
  101.   cmInsMode     = 519,
  102.   cmStartSelect = 520,
  103.   cmHideSelect  = 521,
  104.   cmIndentMode  = 522,
  105.   cmUpdateTitle = 523,
  106.   cmWindowStart = 524,
  107.   cmWindowEnd   = 525;
  108.  
  109. const
  110.   edOutOfMemory   = 0,
  111.   edReadError     = 1,
  112.   edWriteError    = 2,
  113.   edCreateError   = 3,
  114.   edSaveModify    = 4,
  115.   edSaveUntitled  = 5,
  116.   edSaveAs        = 6,
  117.   edFind          = 7,
  118.   edSearchFailed  = 8,
  119.   edReplace       = 9,
  120.   edReplacePrompt = 10;
  121.  
  122. const
  123.   efCaseSensitive   = 0x0001,
  124.   efWholeWordsOnly  = 0x0002,
  125.   efPromptOnReplace = 0x0004,
  126.   efReplaceAll      = 0x0008,
  127.   efDoReplace       = 0x0010,
  128.   efBackupFiles     = 0x0100;
  129.  
  130. const
  131.   maxLineLength = 256;
  132.  
  133. #endif  // __EDIT_COMMAND_CODES
  134.  
  135. typedef ushort (*TEditorDialog)( int, ... );
  136. ushort defEditorDialog( int dialog, ... );
  137.  
  138. #if defined( Uses_TIndicator ) && !defined( __TIndicator )
  139. #define __TIndicator
  140.  
  141. class far TRect;
  142.  
  143. class TIndicator : public TView
  144. {
  145.  
  146. public:
  147.  
  148.     TIndicator( const TRect& );
  149.  
  150.     virtual void draw();
  151.     virtual TPalette& getPalette() const;
  152.     virtual void setState( ushort, Boolean );
  153.     void setValue( const TPoint&, Boolean );
  154.  
  155. protected:
  156.  
  157.     TPoint location;
  158.     Boolean modified;
  159.  
  160. private:
  161.  
  162.     static const char near dragFrame;
  163.     static const char near normalFrame;
  164.  
  165.     virtual const char *streamableName() const
  166.         { return name; }
  167.  
  168. protected:
  169.  
  170.     TIndicator( StreamableInit );
  171.  
  172. public:
  173.  
  174.     static const char * const near name;
  175.     static TStreamable *build();
  176.  
  177. };
  178.  
  179. inline ipstream& operator >> ( ipstream& is, TIndicator& cl )
  180.     { return is >> (TStreamable&)cl; }
  181. inline ipstream& operator >> ( ipstream& is, TIndicator*& cl )
  182.     { return is >> (void *&)cl; }
  183.  
  184. inline opstream& operator << ( opstream& os, TIndicator& cl )
  185.     { return os << (TStreamable&)cl; }
  186. inline opstream& operator << ( opstream& os, TIndicator* cl )
  187.     { return os << (TStreamable *)cl; }
  188.  
  189. #endif  // Uses_TIndicator
  190.  
  191.  
  192. #if defined( Uses_TEditor ) && !defined( __TEditor )
  193. #define __TEditor
  194.  
  195. class far TRect;
  196. class far TScrollBar;
  197. class far TIndicator;
  198. class far TEvent;
  199.  
  200. enum WordWrapState {wwsError, wwsNoWrap, wwsDidWrap};
  201.  
  202. #define TEditorBase TView
  203.  
  204. class TEditor : public TEditorBase
  205. {
  206. public:
  207.  
  208.     friend void genRefs();
  209.  
  210.     TEditor( const TRect&, TScrollBar *, TScrollBar *, TIndicator *, ushort );
  211.     virtual ~TEditor();
  212.  
  213.     virtual void shutDown();
  214.  
  215.     char bufChar( ushort ) const;
  216.     ushort bufPtr( ushort ) const;
  217.     virtual void changeBounds( const TRect& );
  218.     virtual void convertEvent( TEvent& );
  219.     Boolean cursorVisible();
  220.     void deleteSelect(Boolean alwaysWrap=False);
  221.     virtual void doneBuffer();
  222.     virtual void draw();
  223.     virtual TPalette& getPalette() const;
  224.     virtual void handleEvent( TEvent& );
  225.     virtual void initBuffer();
  226.     Boolean insertBuffer( char *, ushort, ushort, Boolean, Boolean, Boolean alwaysWrap=False );
  227.     virtual Boolean insertFrom( TEditor * );
  228.     Boolean insertText( const void *, ushort, Boolean );
  229.     virtual void scrollTo( int, int );
  230.     Boolean search( const char *, ushort );
  231.     virtual Boolean setBufSize( ushort );
  232.     void setCmdState( ushort, Boolean );
  233.     void setSelect( ushort, ushort, Boolean);
  234.     virtual void setState( ushort, Boolean );
  235.     void trackCursor( Boolean );
  236.     void undo();
  237.     virtual void updateCommands();
  238.     virtual Boolean valid( ushort );
  239.  
  240.     int charPos( ushort, ushort );
  241.     ushort charPtr( ushort, int );
  242.     Boolean clipCopy();
  243.     void clipCut();
  244.     void clipPaste();
  245.     void deleteRange( ushort, ushort, Boolean );
  246.     void doUpdate();
  247.     void doSearchReplace();
  248.     void drawLines( int, int, ushort );
  249.     void formatLine(void *, ushort, int, ushort );
  250.     void find();
  251.     ushort getMousePtr( TPoint );
  252.     Boolean hasSelection() {return Boolean(selStart != selEnd);}
  253.     void hideSelect();
  254.     Boolean isClipboard() const {return Boolean(clipboard == this);}
  255.     ushort lineEnd( ushort );
  256.     ushort lineMove( ushor